function registerVLCEvent(event, handler)
{
   var media = getVLC("media");
   if (media) { 
       if (media.attachEvent) media.attachEvent (event, handler);
       else if (media.addEventListener) media.addEventListener (event, handler, false);
       else media["on" + event] = handler;
	}
}

function unregisterVLCEvent(event, handler) {
   var media = getVLC("media");
   if (media) {
	   if (media.detachEvent) media.detachEvent (event, handler);
	   else if (media.removeEventListener) media.removeEventListener (event, handler, false);
	   else media["on" + event] = null;
	}
}

function handleEvents(event) {
   if (!event) event = window.event;
   if (event.target) targ = event.target;
   else if (event.srcElement) targ = event.srcElement;
   else {
       alert("Event value" + event );
       return;
   }
   if (targ.nodeType == 3) targ = targ.parentNode;
   alert("Event " + event.type + " has fired from " + targ );
}

function handleMouseGrab(event,X,Y) {
   if (!event) event = window.event;
   alert("new position (" + X + "," + Y + ")");
}
registerVLCEvent('MediaPlayerNothingSpecial', handleEvents);
registerVLCEvent('MediaPlayerOpening', handleEvents);
registerVLCEvent('MediaPlayerBuffering', handleEvents);
registerVLCEvent('MediaPlayerPlaying', handleEvents);
registerVLCEvent('MediaPlayerPaused', handleEvents);
registerVLCEvent('MediaPlayerForward', handleEvents);
registerVLCEvent('MediaPlayerBackward', handleEvents);
registerVLCEvent('MediaPlayerEncounteredError', handleEvents);
registerVLCEvent('MediaPlayerEndReached', handleEvents);
registerVLCEvent('MediaPlayerTimeChanged', handleEvents);
registerVLCEvent('MediaPlayerPositionChanged', handleEvents);
registerVLCEvent('MediaPlayerSeekableChanged', handleEvents);
registerVLCEvent('MediaPlayerPausableChanged', handleEvents);